import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class ChessController {

	public static void main(String[] args) {
		JFrame frame = new JFrame("wzq");
		frame.setSize(800,600);
		JPanel p = (JPanel) frame.getContentPane();
		p.setLayout(new BorderLayout());
		
		p.add(Constants.northPanel,BorderLayout.NORTH);
		p.add(Constants.view,BorderLayout.CENTER);
		frame.setVisible(true);
	}

	int currentColor = ChessModel.BLACK;
	int otherColor = ChessModel.WHITE;
	boolean single = false;
	boolean allow = true;
	public void pressMouseOnChessPanel(int row, int col) {
		boolean success = Constants.model.putChess(row, col, currentColor);
		if(success){
			Constants.view.repaint();
			Constants.net.sendChessPoint(row,col);
			if(single){
				currentColor = -currentColor;
			}
			int winner = Constants.model.whoWin();
			if(winner!=ChessModel.SPACE){
				JOptionPane.showMessageDialog(null, winner+" qi ying");
			}
		}
	}
	public void putChessByOther(int row, int col) {
		boolean success = Constants.model.putChess(row, col, otherColor);
		if(success){
			Constants.view.repaint();
			int winner = Constants.model.whoWin();
			if(winner!=ChessModel.SPACE){
				JOptionPane.showMessageDialog(null, winner+" qi ying");
			}
		}
		
	}
}
